package de.lmu.mvs.lerngruppenfinder.utils;

import de.lmu.mvs.lerngruppenfinder.MainActivity;
import de.lmu.mvs.lerngruppenfinder.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;

/**
 * Centralized place for application-wide fields and services
 * 
 * Credit:
 * http://arnab.ch/blog/2013/08/asynchronous-http-requests-in-android-using
 * -volley/
 * 
 * @author chris
 * 
 */
public class BaseActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
	    switch (item.getItemId()) {
	        case android.R.id.home:
	        	onBackPressed();
	            return true;
	        case R.id.action_logout:
	        	FileApi.deleteLoginCredentials();
	        	startActivity(new Intent(this, MainActivity.class));
	        	finish();
	        	return true;
	        default:
	            return super.onOptionsItemSelected(item);
	    }
	}
}
